import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;


public class TestDB {
	//201521123091
	public static void runTest() throws SQLException, ClassNotFoundException {
		Connection connection = DriverManager.getConnection(
				"jdbc:mysql://localhost:3306/test", "root", "123456");
		try {
			java.sql.Statement statement = connection.createStatement();
			statement.executeUpdate("CREATE TABLE IF NOT EXISTS Greetings (Message CHAR(20))");
			statement.executeUpdate("INSERT INTO Greetings VALUES ('Hello World!')");
			
			
			ResultSet result = statement.executeQuery("SELECT * FROM Greetings");
			
			if (result.next()) {
				System.out.println(result.getString(1));
			}
			result.close();
			statement.executeUpdate("DROP TABLE Greetings");
		} finally {
			connection.close();
		}
				
	}
	
	
	
	public static void main(String[] args) throws SQLException, ClassNotFoundException {
		runTest();
	}

}
